﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.achievements.data {
    import flash.utils.*;

    public class Achievement {

        public static const UNINIT:String = "uninit";
        public static const STARTED:String = "started";
        public static const FINISHED:String = "finished";
        public static const REWARDED:String = "rewarded";

        public var id:String;
        public var iconUrl:String;
        public var cashcost:int;
        public var displayTitle:String;
        public var displayDescription:String;
        public var isMystery:Boolean;
        public var rewards:Dictionary;
        public var tests:Dictionary;
        public var groupName:String;
        public var state:String = "uninit";
        public var timestamp:Number = 0;
        public var justUpdated:Boolean = false;

        public function Achievement(_arg1:XML, _arg2:String){
            var _local3:XML;
            var _local4:XML;
            super();
            if (_arg1){
                this.id = String(_arg1.@id);
                this.iconUrl = String(_arg1.@icon);
                this.cashcost = int(_arg1.@cashcost);
                this.displayTitle = String(_arg1.text.@title);
                this.displayDescription = String(_arg1.text.@description);
                this.isMystery = (_arg1.text.@mystery == "true");
                this.groupName = _arg2;
                this.rewards = new Dictionary();
                for each (_local3 in _arg1.rewards.reward) {
                    this.rewards[String(_local3.@type)] = String(_local3.@value);
                };
                this.tests = new Dictionary();
                for each (_local4 in _arg1.tests.test) {
                    this.tests[String(_local4.@type)] = _local4;
                };
            };
        }
        public function update(_arg1:Object):void{
            this.state = String(_arg1["state"]);
            this.timestamp = ((_arg1["timestamp"])!=null) ? (Number(_arg1["timestamp"]) * 1000) : 0;
        }
        public function get isDone():Boolean{
            return ((((this.state == Achievement.FINISHED)) || ((this.state == Achievement.REWARDED))));
        }

    }
}//package Modules.achievements.data 
